<template>
  <el-dialog
    v-model="props.visible"
    :footer="false"
    @close="emits('cancel')"
    width="800px"
  >
    <template #header="{ titleId, titleClass }">
      <div class="my-header flex">
        <h4
          :id="titleId"
          :class="titleClass"
        >
          <el-icon>
            <TakeawayBox />
          </el-icon>
          模板库
        </h4>
        <div class="search-box">
          <el-input
            v-model="searchKeyword"
            placeholder="搜索模板"
            class="search-input"
          />
          <el-button
            link
            @click="handleSearch"
            class="search-button"
            :icon="Search"
          >
          </el-button>
        </div>
      </div>
    </template>
    <div class="dialog-content">
      <div class="empty-box">
        <div
          class="empty-Folder flex-center w-120 h-120"
          @click="AddEmptyFolder"
        >
          <div class="empty-Folder-icon w-p-60">
            <FolderAdd />
          </div>
          <p>空白文件夹</p>
        </div>
      </div>
      <div class="basicTemplate-box">
        <h4>基础模板</h4>
        <div class="flex flex-wrap">
          <div
            v-for="(item, index) in 3"
            :key="item"
          >
            <div class="empty-Folder flex-center w-120 h-120">
              <div class="empty-Folder-icon w-p-60">
                <FolderAdd />
              </div>
              <p>文件夹模板{{ index + 1 }}</p>
            </div>
            <div class="flex-center mt-10">
              <el-button
                type="info"
                size="small"
                class="btn"
                @click="previewFolder"
              >预览</el-button>
              <el-button
                type="info"
                size="small"
                class="btn"
                @click="useFolder"
              >使用</el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>
<script setup>
import { Search, CirclePlus } from "@element-plus/icons-vue";
import { addFolder } from "@/api/folder";
import { ElMessage } from 'element-plus'
const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  row: {
    type: Object,
    default: () => { },
  },
});
const emits = defineEmits(["close", "cancel"]);
const searchKeyword = ref("");
const handleSearch = () => {
  console.log("handleSearch");
};
const AddEmptyFolder = () => {
  console.log("AddEmptyFolder");
  addFolder({
    "creationMode": "0", // 0,1,2
    // "templateFolderId": "1" // 公共模板id
    // "templateFolderId": "1" // 我的模板id
  }).then((res) => {
    console.log("res", res);
    if (res.code == 200) {
      ElMessage({
        message: "新建成功!",
        type: "success",
      });
      emits("close");
    }
  });
};
const previewFolder = () => {
  console.log("previewFolder");
};
const useFolder = () => {
  console.log("useFolder");
};
onMounted(() => { });
</script>
<style lang="scss" scoped>
.el-dialog__title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.my-header {
  height: 34px;
  justify-content: space-between;
  .search-box {
    display: flex;
    align-items: center;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    margin-right: 15px;
    .search-input {
      flex: 1;
      border-right: 1px solid #dcdfe6;
      :deep(.el-input__wrapper) {
        box-shadow: none;
      }
      .el-input__icon {
        cursor: pointer;
        font-size: 18px;
        &:hover {
          color: #409eff; /* Element Plus 主色调 */
        }
      }
    }
    .search-button {
      height: 100%;
      padding: 0 8px;
    }
  }
}
.dialog-content {
  max-height: 60vh;
  overflow-y: auto;
}
// .empty-box {
.empty-Folder {
  border: 1px solid #ccc;
  border-radius: 5px;
  flex-direction: column;
}
// }
.basicTemplate-box {
  margin: 30px 0;
  h4 {
    line-height: 50px;
  }
  .flex.flex-wrap {
    gap: 20px;
  }
}
</style>
